/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-04-07     donghaomin       the first version
 */
#ifndef APPLICATIONS_D__FLASH_D_FLASH_H_
#define APPLICATIONS_D__FLASH_D_FLASH_H_

#include "stm32f1xx_hal.h"

/* FLASH大小：64K */
#define STM32FLASH_SIZE  0x00010000UL

/* FLASH起始地址 */
#define STM32FLASH_BASE  FLASH_BASE

/* FLASH结束地址 */
#define STM32FLASH_END   (STM32FLASH_BASE | STM32FLASH_SIZE)

/* FLASH页大小：1K */
#define STM32FLASH_PAGE_SIZE FLASH_PAGE_SIZE

/* FLASH总页数 */
#define STM32FLASH_PAGE_NUM  (STM32FLASH_SIZE / STM32FLASH_PAGE_SIZE)

/// 导出函数声明
void FLASH_Init(void);
unsigned int FLASH_Read(unsigned int Address, void *Buffer, unsigned int Size);
unsigned int FLASH_Write(unsigned int Address, const unsigned short *Buffer, unsigned int NumToWrite);
int FLASH_ErasePage(unsigned int PageAddress, unsigned int NbPages);
unsigned int FLASH_WriteNotCheck(unsigned int Address, const unsigned short *Buffer, unsigned int NumToWrite);


#endif /* APPLICATIONS_D__FLASH_D_FLASH_H_ */
